Skip to content

Fix tool call with empty arguments in streaming mode #4027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

huidongyin
Copy link
Contributor

When method tool or MCP tool with no argument and calling in streaming mode,
errors will occur due to null/empty arguments validation.

This PR adds defensive handling for null/empty tool arguments in streaming mode
by using empty JSON object "{}" as default instead of throwing IllegalArgumentException.

Fixes: #4007

@sobychacko
Copy link
Contributor

See the build errors: https://github.com/spring-projects/spring-ai/actions/runs/16780012117/job/47515816009?pr=4027
Also, please address DCO.
No wildcard imports.

Thanks.

- Add null/empty argument handling in DefaultToolCallingManager
- Add similar handling in SyncMcpToolCallback and AsyncMcpToolCallback
- Add comprehensive test coverage for the fix
- Apply Spring Java format to fix code style violations

Signed-off-by: huidong.yin <[email protected]>
@huidongyin huidongyin force-pushed the fix/stream-tool-call-empty-arguments branch from 051e430 to 91aadd3 Compare August 6, 2025 14:49
@huidongyin
Copy link
Contributor Author

See the build errors: https://github.com/spring-projects/spring-ai/actions/runs/16780012117/job/47515816009?pr=4027 Also, please address DCO. No wildcard imports.

Thanks.

got it ,thanks .

@huidongyin
Copy link
Contributor Author

See the build errors: https://github.com/spring-projects/spring-ai/actions/runs/16780012117/job/47515816009?pr=4027 Also, please address DCO. No wildcard imports.

Thanks.

first time commit code to Spring , not sure what else I need to do.

- Replace java.util.* with specific imports
- Apply Spring Java format to ensure code style compliance

Signed-off-by: huidong.yin <[email protected]>
@huidongyin
Copy link
Contributor Author

Hi @sobychacko ,Please help review if everything looks good ,thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants